-
Notifications
You must be signed in to change notification settings - Fork 60
tests: added test for Body() methods of requests using golden files #450
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
5977e48
to
8897eb5
Compare
8897eb5
to
55de81c
Compare
55de81c
to
fe36442
Compare
// ``` | ||
// Use it to debug the test. | ||
// | ||
// If you want to update the golden file, run delete old file and rerun the test. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's up to you, but I think it would be more reasonable to explicitly create data files with the update-testdata
flag or something similar.
Otherwise, the absence of a control file will result in the test passing successfully.
As for an example, you could check: https://github.com/tarantool/tt/blob/master/cli/tcm/log_test.go#L23
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. Ideally we need to separate generation of data from tests and generate it with go generate
. But a flag a good idea too.
BitwiseOr(8, 11). | ||
BitwiseXor(9, 12) | ||
|
||
for _, tc := range []goldenTestCase{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would probably be better to separate the initialisation of test cases and the logic of the test loop.
// | ||
// If you want to update the golden file, run delete old file and rerun the test. | ||
|
||
func logMsgpackAsJsonConvert(t *testing.T, data []byte) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func logMsgpackAsJsonConvert(t *testing.T, data []byte) { | |
func logMsgpackAsJsonConvert(t *testing.T, data []byte) { | |
t.Helper() |
Helper function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the patch. See comments above.
logMsgpackAsJsonConvert(t, out.Bytes()) | ||
case !compareGoldenMsgpack(t, name, out.Bytes()): | ||
// ??? | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean here? The comment is confusing.
This pull request introduces changes to the test data files for various request types.